﻿using System;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Narwhunderful.Aphelia.Framework.UI;
using Narwhunderful.Aphelia.Framework.UI.Controls;

namespace Narwhunderful.Aphelia.Framework.UI.Controls
{

    public class Textbox : Label
    {

        public Textbox(HUD hud)
            : base(hud)
        {
            base.CanFocus = true;
        }

        protected internal override void OnKeyDown(object sender, Input.Keyboard.KeyEventArgs e)
        {
            if (base.IsFocused)
            {
                switch (e.Keys)
                {
                    case Keys.Left:
                    case Keys.Right:
                    case Keys.Up:
                    case Keys.Down:
                        break;
                    case Keys.Back:
                        if (base.Text.Length > 0) base.Text = base.Text.Substring(0, base.Text.Length - 1);
                        break;
                    case Keys.Enter:
                        //base.Text += Environment.NewLine;
                        break;
                    default:
                        base.Text = base.Text + Input.Keyboard.KeyboardManager.KeyToString(e);
                        break;
                }
            }
            base.OnKeyDown(sender, e);
        }

    }

}
